import 'dart:async';

import 'package:flutter/services.dart';

class AppTool {
  AppTool._();

  static const MethodChannel _channel = const MethodChannel('app_tool');

  /// 安装Apk
  ///
  /// [ path ] apk文件路径
  /// [ applicationName ] 应用名称
  static Future<bool> installApk({
    required String path,
    required String applicationName,
  }) async {
    try {
      final Map<String, String> arguments = {
        'path': path,
        'applicationName': applicationName,
      };

      final String? code = await _channel.invokeMethod<String>('install_apk', arguments);

      return code == '1';
    } catch (e) {
      return false;
    }
  }
}
